Title: SQL W3S (By-BKK) / 115 Auto Increment
Tags: Obsidian_to_Anki

Q: What is SQL AUTO INCREMENT used for?
A: To automatically generate a unique number when a new record is inserted

Q: AUTO INCREMENT can be set for which type of field most commonly?
A: Primary key field

Q: Which keyword is used for auto-increment in MySQL?
A: AUTO_INCREMENT

Q: How do you set an AUTO_INCREMENT field in a MySQL table?
A: Use AUTO_INCREMENT keyword in column definition

Q: True/False: AUTO_INCREMENT starts counting from 1 by default in MySQL
A: True

Q: How do you change the starting value of AUTO_INCREMENT in MySQL?
A: Use ALTER TABLE Persons AUTO_INCREMENT=n

Q: A new record is added to a MySQL table with an AUTO_INCREMENT field. Do you need to specify a value for that field?
A: No, it gets assigned automatically

Q: What keyword does SQL Server use for auto-increment?
A: IDENTITY

Q: How do you set the starting value and increment in SQL Server?
A: Use IDENTITY(start, increment)

Q: True/False: You must specify a value for the auto-increment field when inserting in SQL Server
A: False

Q: Which keyword does MS Access use for auto-increment?
A: AUTOINCREMENT

Q: How can you specify a custom start and increment in MS Access auto-increment?
A: Use AUTOINCREMENT(start, increment)

Q: What must you do to insert a new record into an Access table with AUTOINCREMENT?
A: Omit the auto-increment field; it is generated automatically

Q: How is auto-increment achieved in Oracle SQL?
A: By creating a sequence and using sequence.nextval

Q: True/False: Oracle SQL needs a sequence object for auto-increment
A: True

Q: In Oracle, what does CREATE SEQUENCE do?
A: Sets up a number generator for automatic increment

Q: What function retrieves the next value from an Oracle sequence in SQL?
A: sequence_name.nextval

Q: Starting value for AUTO_INCREMENT in MySQL is 1 by default
A: True

Q: Identity keyword is used for auto-increment in SQL Server
A: True

Q: What is the primary purpose of an AUTO_INCREMENT field in SQL?
A: To automatically generate a unique number for a column